﻿using System.Text.Json;
using System.Text.Json.Serialization;

namespace Bigway.Common;

public static class CommonStatics
{
    public const int ChinaMainlandPhoneNumberLength = 11;
    public const int ConsumeCodeLength = 6;
    public const int ConsumeCodePrefixLength = 2;
    public const string DateFormat = "yyyy-MM-dd";
    public const double ChinaTimeZoneOffset = 8;

    public const string UnknownContentType = "application/unknown";

    public const string ScalarUrl = "scalar/v1";

    public static JsonNamingPolicy DefaultJsonNamingPolicy => JsonNamingPolicy.SnakeCaseLower;

    public static JsonSerializerOptions DefaultJsonOptions { get; } = new JsonSerializerOptions
    {
        PropertyNameCaseInsensitive = true,
        IgnoreReadOnlyProperties = true,
        IgnoreReadOnlyFields = true,
        PropertyNamingPolicy = DefaultJsonNamingPolicy,
        NumberHandling = JsonNumberHandling.AllowReadingFromString
    };

    public static readonly TimeSpan BackgroundJobWaitDefaultDelay = TimeSpan.FromSeconds(1);
}